<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<meta name="author" content="order by dede58.com"/>
	<title>DeathGhost-注册</title>
	<meta name="keywords" content="DeathGhost,DeathGhost.cn,web前端设,移动WebApp开发" />
	<meta name="description" content="DeathGhost.cn::H5 WEB前端设计开发!" />
	<meta name="author" content="DeathGhost"/>
	<link href="style/style.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="js/public.js"></script>
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/jqpublic.js"></script>
	<script type="text/javascript">

		function login(){
			var xhr = new XMLHttpRequest();
			var username= document.getElementById("username").value;
			var email= document.getElementById("email").value;
			var phone= document.getElementById("phone").value;
			var password= document.getElementById("password").value;
			var re_password = document.getElementById("re_password").value;
			//alert(type);
			if(password!=re_password){
				alert("2次输入密码不一致.....");
				document.getElementById("re_password").value = "";
				document.getElementById("re_password").focus();
				return;
			}
			if(!username){
				alert("请输入您的用户名.....");
				document.getElementById("username").value = "";
				document.getElementById("username").focus();
				return;
			}
			if(!email){
				alert("请输入邮箱.....");
				document.getElementById("email").value = "";
				document.getElementById("email").focus();
				return;
			}
			if(!phone){
				alert("请输入手机.....");
				document.getElementById("phone").value = "";
				document.getElementById("phone").focus();
				return;
			}
			if(!password){
				alert("请输入您的密码.....");
				document.getElementById("password").value = "";
				document.getElementById("password").focus();
				return;
			}
			var params = "username="+username+"&password="+password+"&email="+email+"&phone="+phone;
			xhr.open("post","/user/register");
			xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			xhr.onreadystatechange = function(){
				if(this.readyState==4 && this.status==200){
					var text = this.responseText.trim();
					if(text=="success"){
						alert("注册成功.....");
						window.location.href="/gotoLogin";
					}
					if(text=="fail"){
						alert("注册失败.....");
						document.getElementById("password").value = "";
						document.getElementById("password").focus();
					}
				}
			};
			xhr.send(params);

		}



		function checkUserName(){
			var xhr = new XMLHttpRequest();
			var username = document.getElementById("username").value;


			var params = "username="+username;
			xhr.open("post","/user/checkUser");
			xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			xhr.onreadystatechange = function(){
				if(this.readyState==4 && this.status==200){
					var text = this.responseText.trim();
					if(text=="fail"){
						alert("该用户已注册.....");
						document.getElementById("username").value = "";
					}
				}
			};
			xhr.send(params);



		}


	</script>
</head>
<body>
<header>
	<jsp:include   page="commen/head.jsp" flush="true"/>
</header>
<!--Start content-->
<section class="Psection MT20">
	<form>
		<table class="Register">
			<tr>
				<td width="40%" align="right" class="FontW">用户名：</td>
				<td><input type="text" id="username" onblur="checkUserName()" required autofocus></td>
			</tr>
			<tr>
				<td width="40%" align="right" class="FontW">密码：</td>
				<td><input type="password" id="password"  required></td>
			</tr>
			<tr>
				<td width="40%" align="right" class="FontW">再次确认：</td>
				<td><input type="password" id="re_password" required></td>
			</tr>
			<tr>
				<td width="40%" align="right" class="FontW">电子邮件：</td>
				<td><input type="email" id="email" required></td>
			</tr>
			<tr>
				<td width="40%" align="right" class="FontW">手机号码：</td>
				<td><input type="text" id="phone" required pattern="[0-9]{11}"></td>
			</tr>
			<tr>
				<td width="40%" align="right"></td>
				<td><input  onclick="login()" class="Submit_b" value="注 册">( 已经是会员，<a href="/gotoLogin" class="BlueA">请登录</a> )</td>
			</tr>
		</table>
	</form>
</section>
<!--End content-->
<div class="F-link">
	<span>友情链接：</span>




</div>
<footer>
	<section class="Otherlink">
		<aside>
			<div class="ewm-left">
				<p>手机扫描二维码：</p>
				<img src="images/Android_ico_d.gif">
				<img src="images/iphone_ico_d.gif">
			</div>
			<div class="tips">
				<p>客服热线</p>
				<p><i>1830927**73</i></p>
				<p>配送时间</p>
				<p><time>09：00</time>~<time>22:00</time></p>
				<p>网站公告</p>
			</div>
		</aside>
		<section>
			<div>
				<span><i class="i1"></i>配送支付</span>
				<ul>
					<li><a href="article_read.html" target="_blank" title="标题">支付方式</a></li>
					<li><a href="article_read.html" target="_blank" title="标题">配送方式</a></li>
					<li><a href="article_read.html" target="_blank" title="标题">配送效率</a></li>
					<li><a href="article_read.html" target="_blank" title="标题">服务费用</a></li>
				</ul>
			</div>
			<div>
				<span><i class="i2"></i>关于我们</span>
				<ul>
					<li><a href="article_read.html" target="_blank" title="标题">招贤纳士</a></li>
					<li><a href="article_read.html" target="_blank" title="标题">网站介绍</a></li>
					<li><a href="article_read.html" target="_blank" title="标题">配送效率</a></li>
					<li><a href="article_read.html" target="_blank" title="标题">商家加盟</a></li>
				</ul>
			</div>
			<div>
				<span><i class="i3"></i>帮助中心</span>
				<ul>
					<li><a href="article_read.html" target="_blank" title="标题">服务内容</a></li>
					<li><a href="article_read.html" target="_blank" title="标题">服务介绍</a></li>
					<li><a href="article_read.html" target="_blank" title="标题">常见问题</a></li>
					<li><a href="article_read.html" target="_blank" title="标题">网站地图</a></li>
				</ul>
			</div>
		</section>
	</section>
	<div class="copyright">© 版权所有 2020
</footer>
</body>
</html>
